<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    // 输入学生人数，依次输入成绩，求和，平均值
    var sum = 0, avg = 0, score = 0;
    var num = prompt("请输入一共有多少名学生");
    for (var i = 1; i <= num; i++) {
      score = prompt('请输入第' + i + '位学生成绩');
      console.log(score);
      sum += parseInt(score);
      console.log(sum);
    }
    alert("总成绩是" + sum);
    alert("平均分是" + sum / num);
  </script>
</head>

<body>

</body>

</html>